package com.weixing.mall.pay.channel.ali;

import com.alipay.api.AlipayApiException;
import com.alipay.api.request.AlipayDataDataserviceBillDownloadurlQueryRequest;
import com.alipay.api.response.AlipayDataDataserviceBillDownloadurlQueryResponse;
import com.weixing.mall.pay.PayParam;
import com.weixing.mall.pay.PayResult;
import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName AliPayBillDownload
 * @Description
 * @Author Small
 * @Date 2020/7/28 18:00
 * @Version 1.0
 **/
@Slf4j
public class AliPayBillDownload extends AbstractAliPay {


    public AliPayBillDownload(AliPaySet payConfig) {
        super(payConfig);
    }

    /**
     * 下载对账单
     *  @param billDate  账单日期 格式 yyyy-MM-dd
     */
    public void execDown(String billDate) {
        initClient();
        AlipayDataDataserviceBillDownloadurlQueryRequest request = new AlipayDataDataserviceBillDownloadurlQueryRequest();
        request.setBizContent("{" +
                "\"bill_type\":\"trade\"," +
                "\"bill_date\":\"" + billDate + "\"" +
                "  }");
        try {
            AlipayDataDataserviceBillDownloadurlQueryResponse response = alipayClient.execute(request);
            if (response.isSuccess()) {
                System.out.println(response.getBillDownloadUrl());
                System.out.println("调用成功");
            } else {
                System.out.println("调用失败");
            }
        } catch (AlipayApiException e) {
            e.printStackTrace();
        }
    }

    /**
     * 方法描述: 初始化支付请求
     * @Author Small
     * @Date 2019/12/2 16:27
     * @return com.alipay.api.AlipayRequest
     */
    @Override
    public void initAliPayRequest() {

    }

    /**
     * 方法描述: 设置支付请求参数
     * @Author Small
     * @param payParam
     * @Date 2019/12/2 16:27
     * @return com.alipay.api.AlipayRequest
     */
    @Override
    public void setPayRequestParam(PayParam payParam) {

    }

    /**
     * 方法描述: 执行支付请求
     * @Author Small
     * @Date 2019/12/3 14:36
     * @return com.weixing.mall.pay.PayResult
     */
    @Override
    public PayResult executePay() throws AlipayApiException {
        return null;
    }

    /**
     * 方法描述: 获取交易类型
     * @Author Small
     * @Date 2019/12/3 14:37
     * @return com.weixing.mall.pay.channel.ali.WxTradeTypeEnum
     */
    @Override
    public AliTradeTypeEnum getTradeType() {
        return null;
    }


    public static void main(String[] args) {
        AliPaySet paySet = new AliPaySet();
        paySet.setAppid("2016090301844463");
        paySet.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg9wTEGSbzYIMdx/rHVUqFEmFP26XzvibyZLMUjHaUiCEVbIEt1fXEVBZg+GXydbUnmy8Za00JEuVEH97bHcEOZ1+FckZwBHUaU0p61kA/ZxRpcTQYhZA73Nft6hSNj/w0D1Yl5PKVrB5lahX7eK59zp5Peodoih2YVa6TAf7qtAbcsPkUAc+HG+x4vAVSx31pkRMzZI+vw7hf79EvV6f45GVE4tRxMWxJOHaZ+cOUfaH+UkkJ3ccPFhOHzOOwYNpNDtvgvq7uowyma/Zaz2lmA5e4bTjTP8oX+zticy243BQMIeKOSpv2GdZbIuvF7oRenkfN7mIgindUXzF6SZcwwIDAQAB");
        paySet.setMerchantPrivateKey("MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCPAPAm+c85tYVIh4ZzsNfKSrzk+ttOq2RatB+q/E3c7WiLPwBEowlz4STNCBmE+ciKGjo/bWWwmTicCT1/6Stn/6XemDBtPukXDPZJPdnNY8jXlvfxf9AFdVwv2UVae3jZQcXlG3qmiL1pHwTZdf7FhQxzTyS/U8h5hile++hQUZ+CaSE2AgeEsJJ8QjflCo0bJcguatM4Nv0gDsO7XX2V3yuiyw71ezaRL9QF0gLd43KgkU8dg7Ax8dL91WhC9UM9GjcrN9Ue2HHmBs3e8WC29t6EcpSo1jbfKeUqG5+DQWI70c9HP1GbZYbOH9JlgHa4rZL17Xy0uZ0rrpF9JVkrAgMBAAECggEAE9UceTtR+v3qsylggzD2bG67DcKgoaNxcobikXMWVVpzkkQ1hE9cIz8JPIowB9ogbs6+X0eLv9cwG6vIZLHwvCafWWSf6ra72t+IVJYIW8zH8OZWEp8YOXmSRGyMisTu+Kp/iIusEeaK5kZQBNyxbbFLDb7fKM200u3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new AliPayBillDownload(paySet);

        billDownload.execDown("2020-07-27");
    }
}
